﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using UFSoft.UBF.Business;
using UFSoft.UBF.Eventing;
using UFIDA.U9.SM.Ship;
using UFIDA.U9.PM.PO;
using UFSoft.UBF.PL;
using UFIDA.U9.PM.Rcv;
using UFIDA.U9.SM.RMA;
using UFIDA.U9.SM.SO;
using UFIDA.U9.CBO.SCM.Customer;
using UFIDA.U9.CBO.MFG.BOM;


namespace UFIDA.U9.Cust.Cli.PlugBE
{
    /// <summary>
    /// 玖源机械项目
    /// BOM
    /// BOM生成时带入料品超额领料
    /// </summary>
    class JYJXBOMDefaultValueExtend : IEventSubscriber
    {
        //配置XX.sub.xml文件放置到portal/bin下，dll文件放置到portal/ApplicationServer/Libs下
        public void Notify(params object[] args)
        {
            if (args != null && args.Length != 0 && args[0] is EntityEvent)
            {
                BusinessEntity.EntityKey key = ((EntityEvent)args[0]).EntityKey;
                BOMMaster be = key.GetEntity() as BOMMaster;
                if (be == null)
                    return;
                if (be.BOMComponents == null || be.BOMComponents.Count == 0)
                    return;

                foreach (var item in be.BOMComponents)
                {
                    if (item.ItemMaster == null || item.ItemMaster.MfgInfo == null) continue;

                    item.IsOverIssue= item.ItemMaster.MfgInfo.IsAllowExcessMaterial; //允许超额发料
                    item.MaterialType = item.ItemMaster.MfgInfo.IsSueOverType;//超额类型
                    item.StandardMaterialScale=item.ItemMaster.MfgInfo.StandardMaterialScale;//超额比例
                    item.FixedMaterialNum = item.ItemMaster.MfgInfo.StandardMaterialQty;//固定超额量
                }
            }
        }

     
    }
}
